//
//  CommentFrame.m
//  QSBK
//
//  Created by Eric Wang on 4/22/15.
//  Copyright (c) 2015 Eric Wang. All rights reserved.
//

#import "CommentFrame.h"

@implementation CommentFrame


-(void)setComment:(Comment *)comment
{
    _comment = comment;
    
    CGFloat bgViewX = 5.0;
    CGFloat bgViewY = 2.5;
    CGFloat bgViewW = ScreenW-10;
    CGFloat bgViewH ;
//    @property(nonatomic,assign)CGRect headImageview;
    CGFloat headImageviewX = 5;
    CGFloat headImageviewY = 5;
    CGFloat headImageviewW = 40;
    CGFloat headImageviewH = 40;
    self.headImageview = CGRectMake(headImageviewX, headImageviewY, headImageviewW, headImageviewH);
//    @property(nonatomic,assign)CGRect nameLabel;
    
    CGFloat nameLabelX = headImageviewX+headImageviewW+20;
    CGFloat nameLabelY = headImageviewY+5 ;
    CGFloat nameLabelW = 250;
    CGFloat nameLabelH = 20;
    self.nameLabel = CGRectMake(nameLabelX, nameLabelY, nameLabelW, nameLabelH);
//    @property(nonatomic,assign)CGRect contentLabel;
    CGFloat contentLabelX = nameLabelX;
    CGFloat contentLabelY = headImageviewY+headImageviewH+10;
    UIFont *fnt = [UIFont fontWithName:@"HelveticaNeue" size:15];
    CGRect ContentLabel = [_comment.content boundingRectWithSize:CGSizeMake(ScreenW-nameLabelX-15, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:fnt,NSFontAttributeName, nil] context:nil];
    self.contentLabel = CGRectMake(contentLabelX, contentLabelY, ContentLabel.size.width, ContentLabel.size.height);
//    @property(nonatomic,assign)CGRect floorLabel;
    
    CGFloat floorLabelX = ScreenW - 60;
    CGFloat floorLabelY = headImageviewY;
    CGFloat floorLabelW = 60;
    CGFloat floorLabelH = 20;
    self.floorLabel = CGRectMake(floorLabelX, floorLabelY, floorLabelW, floorLabelH);
    
   
    
    self.cellHeight = contentLabelY+ContentLabel.size.height+5;
    bgViewH = self.cellHeight -2.5;
    self.bgView = CGRectMake(bgViewX, bgViewY, bgViewW, bgViewH);
}
@end
